import {toRefs, reactive, Ref} from 'vue'
import {ElMessage, ElMessageBox} from 'element-plus'
import http from '@/plugin/http'

export default function () {

    const state = reactive({
        loading: false,
        total: 0, page: 1, size: 10,
        keyword: '', dataList: [],
        couponId: ''
    })

    // 请求数据
    const loadDataList = async (page?: number, size?: number) => {
        if (page) state.page = page
        if (size) state.size = size
        const res = await http.get('/coupon/goods', {
            page,
            size,
            coupon_id: state.couponId,
        })
        return res
    }

    return {
        ...toRefs(state),
        loadDataList,
    }
}
